#include <bits/stdc++.h>
#include "ImgProcess/ImgProcess.h"
#include "DetectLights/DetectLights.h"
#include "FindArmor/FindArmor.h"

int main(int, char**) {
    /*视频对象声明*/
    cv::VideoCapture capture("视频文件的路径和文件名");

    /*图像处理对象声明*/
    ImgProcess imgProcess;

    /*灯条识别对象声明*/
    DetectLights detectLights;

    /*装甲板识别对象声明*/
    FindArmor findArmor;

    cv::Mat src; /*用于保存视频中每一帧的图像*/
    
    /*视频调用*/
    while(capture.read(src)){

        cv::resize(src,src,cv::Size(640,480));

        cv::imshow("src",src);//显示原图像

        cv::Mat bin_brightness,bin_color; /*用于保存最后的颜色和亮度二值化图像*/

        /*图像处理调用*/
        imgProcess.ImgDistill(src,bin_brightness,bin_color);

        /*显示处理后的图像，代码编写完后可取消注释查看效果*/
        //cv::imshow("brightness",bin_brightness);
        //cv::imshow("color",bin_color);

        std::vector<cv::RotatedRect> lights;
        detectLights.LightsDetector(bin_brightness,bin_color,lights);

        cv::Mat show_ligths=src.clone();

        /*画灯条，在show_lights上画，需要自己写*/

        /*展示灯条*/
        cv::imshow("show_lights",show_ligths);

        cv::Point3f target;
        /*识别目标，装甲板识别的效果展示需要自己在函数中写*/
        findArmor.FindTarget(lights,target);

        std::cout<<target<<std::endl;


        
        
        
        
        
        
        cv::waitKey(1000/24);
    }
    return 0;
}
